<!--
 * @Author: 邢奇妍 256637363@qq.com
 * @Date: 2025-09-25 08:55:15
 * @LastEditors: 邢奇妍 256637363@qq.com
 * @LastEditTime: 2025-09-26 15:49:40
 * @FilePath: \团队项目\teamwork8\am-ui\src\pages\am\order\Repairs.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
    <div>
        <div class="one">
            <label style="line-height: 3;" class="el-form-item_label">
                工程设备
            </label>
            <div class="block" style="margin-bottom:15px;">
                <span class="demonstration"></span>
                <el-cascader class="cascader" :props="{label:'name',value:'id'}"  :options="EngData" @change="handleChange"></el-cascader>
            </div>
            <label style="line-height: 3;" class="el-form-item_label">
                保修原因
            </label>
            <div style="margin-top: 10px 0;"></div>
            <el-input clearable type="textarea" placeholder="请输入内容" v-model="params.bill_why" show-word-limit>
            </el-input>
            <div style="line-height: 3;" class="demo-drawer__footer">

                 <el-button type="primary" @click="toSubmit">提交</el-button>
            </div>
        </div>
    </div>
</template>

<script>
import {get,postJSON } from '@/utils/request'
export default {
    data() {
        return {
             filterText: '',
            defaultProps: {
                children: 'children',
                label: 'name'
            },
            // 树形结构展示数据
            EngData:[],
            text: '',
            textarea: '',
            params:{
              account_id:1
            }
        };
    },
     watch: {
        // 监听输入框输入值并进行过滤
        filterText(val) {
            this.$refs.tree.filter(val);
        }
    },
    computed: {

    },
    methods: {
      async toSubmit(){
        // 发起报修请求 
        let res = await postJSON('/workorder/repairOrder',this.params);
        if(res.status){
          this.$message({
            type:"success",
            message:res.message
          });
        }
        // 页面跳转 
        this.$router.push('/am/order/List')
      },
      handleChange(value){
        console.log(value);
        this.params.engineer_id = value[0];
        this.params.device_id = value[1];
      },
       async getEngData(){
            let res=await get('/engineer/findEngineerDeviceTree');
            
            this.EngData=res.data;
        },
       filterNode(value, data) {
            if (!value) return true;
            // value输入框输入的值
            // 返回就是包含输入框的关键字的label（节点）
            return data.name.indexOf(value) !== -1;
        }
    },
    created() {
        this.getEngData();
    },
    mounted() { },
};
</script>
<style lang="scss" scoped>
.tree{
    height: calc(100vh - 60px);
  
    padding-right:10px;
}

.demo-drawer__footer {
  
  
  
  bottom: 50px;
  width: 50%;
  text-align: left;
}
.cascader{
    width: 100%;
}
</style>